from rest_framework import serializers
from .models import *


class ClassroomSer(serializers.ModelSerializer):
    class Meta:
        model = Classroom
        fields = "__all__"

    # def create(self, validated_data):
    #     return Classroom.objects.create(**validated_data)
    #
    # def update(self, instance, validated_data):
    #     instance.class_name = validated_data.get("class_name", instance.class_name)
    #     instance.address = validated_data.get("address", instance.address)
    #     instance.save()
    #     return instance
    #
    # def validate(self, attrs):
    #     if attrs.get("address") != '北京':
    #         raise serializers.ValidationError('你的信息不是北京')
    #     return attrs


class RoleSer(serializers.ModelSerializer):
    class Meta:
        model = Role
        fields = "__all__"


class UserSer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = "__all__"
